/**
 * 
 */
package org.intelligentsia.temporal.primitives;

import java.lang.reflect.Method;

import org.intelligentsia.temporal.TransactionTime;

/**
 * @author <a href="mailto:jguibert@intelligents-ia.com" >Jerome Guibert</a>
 * 
 */
public class ObjectTemporal extends BaseTemporal<Object> {

	private static final long	serialVersionUID	= -3402580941880986124L;
	private Method				clone				= null;

	public ObjectTemporal() {
		super();
	}

	public ObjectTemporal(final TransactionTime transactionTime, final Object value) {
		super(transactionTime, value);
	}

	/**
	 * @see org.intelligentsia.temporal.primitives.BaseTemporal#getValue()
	 */
	@Override
	public Object getValue() {
		try {
			if (clone == null) {
				clone = value.getClass().getMethod("clone");
			}
			return clone.invoke(value);
		} catch (final Throwable e) {
			throw new IllegalStateException(e);
		}
	}

}
